package main.www.wonderfuldata.servlet;

import main.www.wonderfuldata.PreparedStatement.PreparedStatementTest;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "delectBookInfo",urlPatterns = "/delectBookInfo")
public class delectBookInfo  extends HttpServlet {

    @Override
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置字符编码
        request.setCharacterEncoding("utf8");



        String bookId =  request.getParameter("id");
        PreparedStatementTest ps = new PreparedStatementTest();
        String sql = "DELETE FROM bookInfo WHERE (bookId=?)";
        ps.update(sql,bookId);
        response.setHeader("Refresh","0;url=selectBook.jsp");



    }
}
